package org.kmfdm.horrorscope.tapestry.components;



import org.apache.tapestry5.*;
import org.apache.tapestry5.annotations.*;
import org.apache.tapestry5.ioc.annotations.*;
import org.apache.tapestry5.BindingConstants;
import org.kmfdm.horrorscope.metamodel.Customer;
import org.kmfdm.horrorscope.metamodel.User;

/**
 * Layout component for pages of application horrorscope.
 */
@IncludeStylesheet("context:layout/layout.css")
public class Layout
{
	
	@SessionState 
	private User user;
	
	public User getUser() {
		return user;
	}
	public void setUser(User user) {
		this.user = user;
	}


	private boolean userExists;
	
    
	
	public boolean isLoggedIn(){
		if (!userExists) return false;
		return true;
	}
	public boolean isNotLoggedIn(){
		if (!userExists) return true;
		return false;
	}
	
	
    /** The page title, for the <title> element and the <h1> element. */
    @Property
    @Parameter(required = true, defaultPrefix = BindingConstants.LITERAL)
    private String title;

    @Property
    private String pageName;

    @Property
    @Parameter(defaultPrefix = BindingConstants.LITERAL)
    private String sidebarTitle;

    @Property
    @Parameter(defaultPrefix = BindingConstants.LITERAL)
    private Block sidebar;

    @Inject
    private ComponentResources resources;

    public String getClassForPageName()
    {
      return resources.getPageName().equalsIgnoreCase(pageName)
             ? "current_page_item"
             : null;
    }

    public String[] getPageNames()
    {
      return new String[] { "Index", "user/Register", "user/LoginUser" };
    }
}
